/*
 *  Copyright (C) 2010 Matthias Buch-Kromann <mbk.isv@cbs.dk>
 * 
 *  This file is part of the MatrixParser package.
 *  
 *  The MatrixParser program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 * 
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.osdtsystem.matrixparser.features.keys;

/**
 *
 * @author Matthias Buch-Kromann <mbk.isv@cbs.dk>
 */
public final class StringList2 extends AbstractStringList {
    String group = "";
    String f1 = "", f2 = "";

    public StringList2() {
    }

    public StringList2 copy() {
        return new StringList2().set(group, f1, f2);
    }

    public StringList2 set(String group, String f1, String f2) {
        this.group = group;
        this.f1 = f1;
        this.f2 = f2;
        this.hashcode = _hashCode();
        return this;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final StringList2 other = (StringList2) obj;
        if (! this.group.equals(other.group)) {
            return false;
        }
        if (! this.f1.equals(other.f1)) {
            return false;
        }
        if (! this.f2.equals(other.f2)) {
            return false;
        }
        return true;
    }

    @Override
    public int _hashCode() {
        int hash = 5;
        hash = 79 * hash + this.group.hashCode();
        hash = 79 * hash + this.f1.hashCode();
        hash = 79 * hash + this.f2.hashCode();
        return hash;
    }

    @Override
    public String toString() {
        StringBuilder s = new StringBuilder();
        s.append(group).append(FIELDSEP).append(f1).append(FIELDSEP).append(f2);
        return s.toString();
    }    
}
